package guoanmaker.operator.helper.common.util;

import org.json.JSONObject;

import guoanmaker.operator.business.model.PayInfo;

public class PayAnaiyInfor {
	public static PayInfo getPayInfo(String json,String channel)throws Exception{
		PayInfo payInfo=new PayInfo();
		JSONObject dataJson=new JSONObject(json);
		String status=dataJson.getString("status");
		if(status!=null&&status.equals("SUCCESS")){
			payInfo.setStatus(status);
			payInfo.setId(dataJson.getString("id"));
			if(channel!=null&&channel.equals("wx_pub_qr")){
				JSONObject wx=dataJson.getJSONObject("credential");
				if(wx!=null){
					payInfo.setWx_pub_qr(wx.getString("wx_pub_qr"));
				}
			}else if(channel!=null&&channel.equals("alipay_pc_direct")){
				payInfo.setAlipay_code(dataJson.getString("alipay_code"));
			}else if(channel!=null&&channel.equals("kq")){
				payInfo.setKq_code(dataJson.getString("kq_code"));
			}
		}
		return payInfo;
	}
}
